TARGET		= libiobase.a
SRCS		= $(wildcard *.cpp)
OBJS     	= $(patsubst %.cpp, %.o, $(SRCS))
TMP_DIR		= obj
TARGET_OBJS	= $(addprefix $(TMP_DIR)/, $(OBJS))
CXXFLAG		= -Wall -g -ggdb -Wextra -pipe -Wno-invalid-offsetof
INC_PATH	= -I/
LIB_PATH	= -L/
LIBS		= -lm -lc -lpthread
DEFINE		= -DLINUX_OS -DDEBUG -DTCP_DEFER_ACCEPT

BITS=$(shell getconf LONG_BIT)
ifeq ($(BITS),64)
CXXFLAG += -m64
else
CXXFLAG += -m32
endif

.PHONY : all clean depend

all : depend $(TARGET)

-include .depend

$(TARGET) : $(TARGET_OBJS)
	ar -r -o $@ $^

$(TMP_DIR)/%.o : %.cpp
	$(CXX) $(CXXFLAG) $(DEFINE) $(INC_PATH) -c $< -o $@

depend :
	$(CXX) -MM $(CXXFLAG) $(INC_PATH) $(SRCS) > .depend
	@-(./replace.sh)

clean:
	@-(rm $(TMP_DIR)/*.o $(TARGET) .depend)
